import { post } from '@/utils/request'

export function login(data) {
  return post('/user/login', data, {
    transformRequest: [function(data) {
      let ret = ''
      for (const it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

export function getInfo(token) {
  return post('/login/user/info?token=' + token)
}

export function logout() {
  return post('/user/logout', {})
}

export function reg(data) {
  return post('/metadata/sys/v1/reg', data)
}
